{% extends "base_view.html" %}
{% load forum_tags %}
{% load static %}

{%  block title %}
    New Post
{%  endblock %}

{% block headtitle %}
    New Post
{% endblock %}

<script async src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>

{% block container %}
    <div class="ui bottom attached create-post segment">
        {% show_messages messages %}
        {% block content %}

            {% form_errors form=form wmd_prefix='wmd-input' override_content=True %}

            <div class="ui basic compact segment no-shadow">

                <div class="ui center aligned medium header">Create a new post</div>

                <div class="ui form-wrap segment">

                    <form method="post" class="ui  form" action="{{ action_url }}">

                        {{ form.media }}
                        {% csrf_token %}


                        <div class="required field">
                            <label>{{ form.title.label }}</label>
                            {{ form.title }}
                            <p class="muted">{{ form.title.help_text }}</p>
                        </div>


                        <div class="required field">
                            <label>{{ form.post_type.label }}</label>
                            {{ form.post_type }}
                            <p class="muted" style="display: contents; ">{{ form.post_type.help_text }} Click here for
                                more</p> {% include 'forms/help_text.html' %}
                        </div>


                        <div class="required field">
                            <label>{{ form.tag_val.label }}</label>
                            {% block new_tag_val %}
                            {{ form.tag_val }}
                            {% endblock %}
                            <p class="muted">{{ form.tag_val.help_text }}</p>
                        </div>


                        <div class="required input field">
                            {% include 'widgets/post_message.html' %}
                            {% include 'widgets/textarea.html' with boilerplate=True %}
                        </div>

                        <div class="ui preview segment"></div>

                        {% if form.captcha %}
                            <div class="top-padding">
                                <div class="required field">
                                    {{ form.captcha }}
                                </div>
                            </div>
                        {% endif %}

                        <div class="top-padding">
                            <button type="submit" class="ui submit green button">
                                <i class="check icon"></i>Submit
                            </button>
                            <a class="ui right floated button" onclick="window.history.back()">
                                <i class="undo icon"></i>Cancel
                            </a>
                        </div>

                    </form>

                </div>

            </div>
        {% endblock %}
    </div>

    <script>
        autocomplete_users();
    </script>
{% endblock %}
